--
-- 鉴权.
--

local access_user_agent = require("src.access_phase.access_user_agent")
local access_ip = require("src.access_phase.access_ip")

local fmt = string.format

local function access()
  local is_filter_ip = ngx.ctx.is_filter_ip
  local is_filter_user_agnet = ngx.ctx.is_filter_user_agnet
  ngx.log(ngx.DEBUG, fmt("access is_filter_ip= %s, is_filter_user_agnet= %s", tostring(is_filter_ip), tostring(is_filter_user_agnet)))

  if not is_filter_ip or not is_filter_user_agnet then
    -- 显示Cloak页面
    ngx.say('Cloak Page!')
    ngx.exit(ngx.HTTP_OK)
  end
end

access_user_agent.access()
access_ip.access()
access()